<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:p="http://primefaces.org/ui"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:au="http://java.sun.com/jsf/composite/autocomplete"
                xmlns:pe="http://primefaces.org/ui/extensions"
                template="/resources/template/template.xhtml">

    <ui:define name="content">
        <h:form>
            <p:panel header="Manage Person Institutions(Channeling)" >
                <p:panel>
                    <p:outputLabel value="Instituion" />
                    <au:institution value="#{personInstitutionController.institution}" ></au:institution>
                    <au:completeDoctorSpeciality value="#{personInstitutionController.speciality}" />
                    <p:commandButton value="Fill Doctors" action="#{personInstitutionController.createWithOutInstitutionPersonsStaffs}" ajax="false" />
                </p:panel>
                <p:panel>
                    <p:dataTable  value="#{personInstitutionController.withOutInstitutionPersonsStaffs}" 
                                  var="s" 
                                  rowKey="#{s.id}" 
                                  selection="#{personInstitutionController.selectedList}"
                                  rowIndexVar="i"
                                  scrollable="true"
                                  scrollHeight="250">
                        <p:column  selectionMode="multiple" >                            
                        </p:column>
                        <p:column >
                            <f:facet name="header" >
                                <h:outputLabel value="No" />
                            </f:facet>
                            <h:outputLabel value="#{i+1}" />
                        </p:column>
                        <p:column>
                            <f:facet name="header" >
                                <h:outputLabel value="Doctor Name"  />
                            </f:facet>
                            <h:outputLabel value="#{s.person.name}"/>
                        </p:column>
                        <p:column>
                            <f:facet name="header" >
                                <h:outputLabel value="Speciality"  />
                            </f:facet>
                            <h:outputLabel value="#{s.speciality.name}"/>
                        </p:column>
                    </p:dataTable>
                    <p:commandButton value="Add Doctors" action="#{personInstitutionController.addStaffToInstitutionPersons}" ajax="false" />
                </p:panel>
                <p:panel header="Person Institutions Search">
                    <h:panelGrid columns="2">
                        <p:outputLabel value="Instituion" />
                        <au:institution value="#{personInstitutionController.reportKeyWord.institution}" />
                        <p:outputLabel value="Speciality" />
                        <au:completeDoctorSpeciality value="#{personInstitutionController.reportKeyWord.speciality}" />
                        <p:outputLabel value="Staff" />
                        <au:completeConsultant value="#{personInstitutionController.reportKeyWord.staff}" />
                        <p:commandButton value="Fill Person Institutions" action="#{personInstitutionController.fillStaffInstitutionPersons}" ajax="false" />
                        <p:commandButton ajax="false" value="Excel" styleClass="noPrintButton" onclick="onSubmitButton();" >
                            <pe:exporter type="xlsx" target="tb1" fileName="Channel_Doctor_List"/>
                        </p:commandButton>
                    </h:panelGrid>
                    <p:dataTable  value="#{personInstitutionController.institutionPersons}" 
                                  var="pi" 
                                  id="tb1" styleClass="noBorder summeryBorder"
                                  rowKey="#{pi.id}" 
                                  rowIndexVar="i"
                                  scrollable="true"
                                  scrollHeight="250">
                        <p:column >
                            <f:facet name="header" >
                                <h:outputLabel value="No" />
                            </f:facet>
                            <h:outputLabel value="#{i+1}" />
                        </p:column>
                        <p:column >
                            <f:facet name="header" >
                                <h:outputLabel value="Doctor Name" />
                            </f:facet>
                            <h:outputLabel value="#{pi.staff.person.name}"/>
                        </p:column>
                        <p:column >
                            <f:facet name="header" >
                                <h:outputLabel value="Speciality"  />
                            </f:facet>
                            <h:outputLabel value="#{pi.staff.speciality.name}"/>
                        </p:column>
                        <p:column rendered="#{personInstitutionController.reportKeyWord.institution eq null}" >
                            <f:facet name="header" >
                                <h:outputLabel value="Institution Name" />
                            </f:facet>
                            <h:outputLabel value="#{pi.institution.name}"/>
                        </p:column>
                        <p:column >
                            <f:facet name="header" >
                                <h:outputLabel value="Code" />
                            </f:facet>
                            <h:outputLabel value="#{pi.staff.code}"/>
                        </p:column>
                        <p:column >
                            <f:facet name="header" >
                                <h:outputLabel value="phone" />
                            </f:facet>
                            <h:outputLabel value="#{pi.staff.person.phone}"/>
                        </p:column>
                        <p:column >
                            <f:facet name="header" >
                                <h:outputLabel value="Mobile" />
                            </f:facet>
                            <h:outputLabel value="#{pi.staff.person.mobile}"/>
                        </p:column>
                        <p:column >
                            <f:facet name="header" >
                                <h:outputLabel value="Remove" />
                            </f:facet>
                            <p:commandButton action="#{personInstitutionController.removeStaffToInstitutionPersons(pi)}" value="Remove" ajax="false" />
                        </p:column>
                    </p:dataTable>
                </p:panel>
            </p:panel>
        </h:form>
    </ui:define>

</ui:composition>
